package com.css.fxfzxczh.modules.disasterDamageInfo.controller;

import com.css.fxfzxczh.base.response.RestResponse;
import com.css.fxfzxczh.modules.disasterDamageInfo.service.DisasterService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: xzy
 * @CreateTime: 2024/3/22 9:22
 * @Description: 仪器烈度
 */
@RestController
@RequestMapping("/disasterDamageInfo")
@Slf4j
public class DisasterController {

    @Resource
    private DisasterService disasterService;


    @PostMapping("disasterDamageImport/{attachId}/{category}")
    public RestResponse importExcel(@PathVariable String attachId,@PathVariable String category) {
        RestResponse restResponse=null;
        try {
            disasterService.importExcel(attachId,category);
            restResponse = RestResponse.succeed();
            restResponse.setMessage("导入成功");
        } catch (Exception e) {
            String errormessage = e.getMessage();
            if(StringUtils.isBlank(errormessage)) {
                errormessage = "导入失败";
            }
            log.error(errormessage,e);
            restResponse=RestResponse.fail(errormessage);
        }
        return restResponse;
    }

}
